package sy.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;

import sy.model.AppComment;
import sy.service.AppCommentServiceI;
import sy.util.ResultJson;

@Controller
@RequestMapping("jsRegister")
public class JSRegistServiceController {
	@Autowired
	AppCommentServiceI appCommentService;



	@RequestMapping(value="/sensitive/event")
	@ResponseBody
	public ResultJson getEnergy(HttpServletRequest request) throws IOException{

		request.setCharacterEncoding("UTF-8");         //返回页面防止出现中文乱码
		BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));//post方式传递读取字符流
		String jsonStr = null;
		StringBuilder result = new StringBuilder();
		try {
			while ((jsonStr = reader.readLine()) != null) {
				result.append(jsonStr);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		reader.close();// 关闭输入流
		JSONObject jsonObject = JSONObject.parseObject(result.toString()); // 取一个json转换为对象
		ResultJson resultJson = new ResultJson();
		resultJson.setErrorCode(200);
		resultJson.setMessage("调试成功");
		resultJson.setState(true);
		resultJson.setResult(jsonObject);
		return resultJson;
	}
}
